package com.iqik.rocket.controller;

import com.iqik.rocket.service.OrderService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {

    @Autowired
    private OrderService orderServer;

    @RequestMapping(value = "/order/{id}")//, method = RequestMethod.POST)
    public String order(@PathVariable(value = "id") String goodId) {
        String order = orderServer.createOrder(goodId);
        if ("false".equals(order)) {
            return "fail";
        }
        return order;
    }

    @RequestMapping(value = "/pay/{id}")
    public String pay(@PathVariable(value = "id") String orderId) {
        return orderServer.payOrder(orderId);
    }
}
